package com.luyang.framework.lock.enums;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * Redisson 连接方式
 *
 * @author lu_yang
 */
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum ConnectionTypeEnum {

    /**
     * 单机
     */
    STANDALONE("standalone"),

    /**
     * 烧饼
     */
    SENTINEL("sentinel"),

    /**
     * 集群
     */
    CLUSTER("cluster"),

    /**
     * 主从
     */
    MASTER_SLAVE("master-slave");

    private final String code;

    public static ConnectionTypeEnum getEnumByCode(String code) {
        return
            Arrays
                .stream(ConnectionTypeEnum.values())
                .filter(v -> v.getCode().equals(code))
                .findFirst()
                .orElse(null);
    }
}
